package com.test.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.test.mapper.HouseMapper;
import com.test.pojo.House;
import com.test.service.HouseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class HouseServiceImpl implements HouseService {

    @Autowired
    private HouseMapper houseMapper;

    @Override
    public PageInfo<House> findHouseLikeTitle(String title, int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize); // ✅ 关键
        House param = new House();
        if (title != null && !title.trim().isEmpty()) {
            param.setTitle("%" + title + "%");
        }
        List<House> list = houseMapper.selectHouseList(param);
        return new PageInfo<>(list);
    }
    @Override
    public int deleteHouseByIds(Integer[] ids) {
        return houseMapper.deleteHouseByIds(ids);
    }

    @Override
    public int insertHouse(House house) {
        return houseMapper.insertHouse(house);
    }
    @Override
    public int updateHouseById(House house) {
        return houseMapper.updateHouseById(house);
    }

}